package com.wingsoft.homeFlow.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.wingsoft.common.annotation.Log;
import com.wingsoft.common.enums.BusinessType;
import com.wingsoft.common.result.Result;
import com.wingsoft.homeFlow.bo.HomeFlowTaskVarAddBo;
import com.wingsoft.homeFlow.bo.HomeFlowTaskVarQo;
import com.wingsoft.homeFlow.bo.HomeFlowTaskVarUptBo;
import com.wingsoft.homeFlow.bo.HomeFlowTaskVarVo;
import com.wingsoft.homeFlow.service.HomeFlowTaskVarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping( "/flowTaskVar")
public class HomeFlowTaskVarController {

    @Autowired
    private HomeFlowTaskVarService homeFlowTaskVarService;

    @PostMapping("/page")
    public Result<Page<HomeFlowTaskVarVo>> page(@RequestBody HomeFlowTaskVarQo homeFlowTaskVarQo) {
        return Result.success(homeFlowTaskVarService.page(homeFlowTaskVarQo));
    }

    @PostMapping("/get/{id}")
    public Result<?> getVoById(@PathVariable("id") String id) {
        return Result.success(homeFlowTaskVarService.getVoById(id));
    }

    @Log(title = "门户流水线任务变量新增", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<?> add(@RequestBody HomeFlowTaskVarAddBo homeFlowTaskVarAddBo) {
        homeFlowTaskVarService.add(homeFlowTaskVarAddBo);
        return Result.success();
    }

    @Log(title = "门户流水线任务变量更新", businessType = BusinessType.UPDATE)
    @PostMapping("/uptById")
    public Result<?> uptById(@RequestBody HomeFlowTaskVarUptBo homeFlowTaskVarUptBo) {
        homeFlowTaskVarService.uptById(homeFlowTaskVarUptBo);
        return Result.success();
    }

    @Log(title = "门户流水线任务变量更新状态", businessType = BusinessType.UPDATE)
    @PostMapping("/uptStatusById")
    public Result<?> uptStatusById(@RequestBody HomeFlowTaskVarUptBo homeFlowTaskVarUptBo) {
        homeFlowTaskVarService.uptStatusById(homeFlowTaskVarUptBo);
        return Result.success();
    }

    @Log(title = "门户流水线任务变量更新全局标识", businessType = BusinessType.UPDATE)
    @PostMapping("/uptGlobalFlagById")
    public Result<?> uptGlobalFlagById(@RequestBody HomeFlowTaskVarUptBo homeFlowTaskVarUptBo) {
        homeFlowTaskVarService.uptGlobalFlagById(homeFlowTaskVarUptBo);
        return Result.success();
    }

    @Log(title = "门户流水线任务变量删除", businessType = BusinessType.DELETE)
    @PostMapping("/del/{id}")
    public Result<?> delById(@PathVariable("id") String id) {
        homeFlowTaskVarService.delById(id);
        return Result.success();
    }

}
